package com.slink.xin.common.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * 上下文工具类
 * 
 * @author 新
 * 
 */
public class XinApplicationContext implements ApplicationContextAware {

	public static ApplicationContext ctx;

	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		XinApplicationContext.ctx = applicationContext;
	}

	/**
	 * 获取spring容器对象
	 * 
	 * @param requiredType
	 * @return
	 */
	public static <T> T getBean(Class<T> requiredType) {
		return XinApplicationContext.ctx.getBean(requiredType);
	}

}
